package org.nowcoder.leetcode.twoPointers;

/**
 * Title  : 9. Palindrome Number
 * Source : https://leetcode.cn/problems/palindrome-number/?envType=study-plan-v2&envId=top-interview-150
 * Author : XrazYang
 * Date   : 2023-08-24
 */
public class LeetCode_9 {
    public boolean isPalindrome(int x) {
        //边界条件
        if (x < 0) {
            return false;
        }
        if (x < 10) {
            return true;
        }
        String s = String.valueOf(x);
        int left = 0;
        int right = s.length() - 1;
        while (left <= right) {
            char l = s.charAt(left);
            char r = s.charAt(right);
            if (l != r) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
